import request from '@/utils/request'

export function getCategoryList(params: CategoryListParamsType) {
  return request<CategoryListType>({
    url: '/product/category',
    method: 'get',
    params,
  })
}

export function setCategoryStatus(id: number, status: number) {
  return request({
    url: `/product/category/set_show/${id}/${status}`,
    method: 'put',
  })
}

export function submitCategory(data: CategoryFormType, id: number | null) {
  return request({
    url: id ? `/product/category/${id}` : '/product/category',
    method: id ? 'put' : 'post',
    data,
  })
}

export function deleteCategory(id: number) {
  return request({
    url: `/product/category/${id}`,
    method: 'delete',
  })
}
